package com.hankol.newretail.fragment

import android.annotation.SuppressLint
import android.graphics.Color
import android.os.Bundle
import android.view.View
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager
import com.baselibrary.Constants
import com.baselibrary.MessageBus
import com.baselibrary.bean.BannerConfigListBean
import com.baselibrary.extension.checkNotNull
import com.baselibrary.extension.checkValue
import com.baselibrary.extension.load
import com.baselibrary.manager.SensorsDataManager
import com.baselibrary.router.ActivityRouter
import com.baselibrary.utils.*
import com.baselibrary.utils.EventBusUtils.sendNotify
import com.baselibrary.view.CenterLayoutManager
import com.baselibrary.view.banner.BannerConfig
import com.baselibrary.view.banner.Transformer
import com.baselibrary.view.banner.listener.OnBannerListener
import com.baselibrary.view.banner.loader.GlideImageLoader
import com.google.android.material.appbar.AppBarLayout
import com.baselibrary.activity.BaseFragment
import com.hankol.newretail.R
import com.hankol.newretail.adapter.HomeMallTabPagerAdapter
import com.hankol.newretail.adapter.MallMenuAdapter
import com.hankol.newretail.adapter.MallNewEnjoyAdapter
import com.hankol.newretail.adapter.MallTabAdapter
import com.hankol.newretail.bean.*
import com.hankol.newretail.databinding.FragmentHomeMallBinding
import com.hankol.newretail.utils.IpOnBannerListener
import com.hankol.newretail.viewmodel.HomeMallViewModel
import com.meiqia.core.MQManager
import com.meiqia.core.bean.MQMessage
import com.meiqia.core.callback.OnGetMessageListCallback
import org.greenrobot.eventbus.EventBus
import org.greenrobot.eventbus.Subscribe
import org.greenrobot.eventbus.ThreadMode


/**新零售-商城首页
 * @author: merbng
 * @time: 2022/4/19 13:37
 * @description:
 */
class HomeMallFragment : BaseFragment(), View.OnClickListener {

    private lateinit var binding: FragmentHomeMallBinding
    private lateinit var mViewModel: HomeMallViewModel

    private val menuAdapter by lazy { MallMenuAdapter(requireActivity()) }
    private val mallTabAdapter by lazy { MallTabAdapter() }
    private val newEnjoyAdapter by lazy { MallNewEnjoyAdapter() }
    val centerLayoutManager = CenterLayoutManager(activity);
    val mTabPagerAdapter by lazy { HomeMallTabPagerAdapter(childFragmentManager) }

    private var mDataBean: HomeMallInfoBean? = null

    var page = 1

    companion object {
        fun newInstance(): HomeMallFragment {
            return HomeMallFragment()
        }
    }

    override fun getLayoutId(): Int {
        return R.layout.fragment_home_mall
    }

    override fun init() {
        binding = getDataBinding<FragmentHomeMallBinding>()
        SensorsDataManager.instance.onCreateTime()
        mViewModel = getFragmentViewModelProvider(this).get(HomeMallViewModel::class.java)
        initView()
    }

    private fun initView() {
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this)
        }
        binding.llLoading.visibility = View.VISIBLE
        binding.smartRefresh.setEnableLoadMore(false)
        binding.smartRefresh.setOnRefreshListener {
            requestData()
        }
        initMenu()
        initTab()
        initListener()
        initObserver()
        requestData()
    }

    val searchKeyList = mutableListOf<String>()

    private fun initSearch() {
        //滚动的评论
        binding.marqueeView.setDisplayedChild(0)
        binding.marqueeView.removeAllViews()
        binding.marqueeView.isAutoStart = false
        for (evaluateBean in searchKeyList) {
            val inflateView = View.inflate(requireContext(), R.layout.view_evaluate_layout, null)
            inflateView.findViewById<TextView>(R.id.tv_evaluate).text = evaluateBean.checkValue()
            inflateView.findViewById<TextView>(R.id.tv_evaluate).setOnClickListener {
                //打开搜索
                if (!DoubleClickHelper.isOnDoubleClick()) {
                    val bundle = Bundle()
                    bundle.putInt(IntentKey.SEARCH_TYPE, 1)
                    bundle.putString(IntentKey.SEARCH_KEY_WORD, evaluateBean.checkValue())
                    ActivityRouter.startActivity(ActivityRouter.ACTIVITY.SEARCH_ALL, bundle)
                }
            }
            binding.marqueeView.addView(inflateView)
        }
        binding.llSearch.visibility = if (searchKeyList.size == 0) View.GONE else View.VISIBLE
        binding.tvOpenSearch.visibility = if (searchKeyList.size == 0) View.VISIBLE else View.GONE
        if (searchKeyList.size > 1) {
            binding.marqueeView.startFlipping()
        } else {
            binding.marqueeView.stopFlipping()
        }
    }

    var tempTotalBannerSize = 0;
    private fun initBanner(bean: BannerConfigListBean) {
        val data = bean.bannerConfigs
        //顶部banner
        val bannerList = arrayListOf<String>()
        val routeUrlList = arrayListOf<String>()
        val nameList = arrayListOf<String>()
        for (topBannerBean in data) {
            bannerList.add(topBannerBean.img.checkValue())
            routeUrlList.add(topBannerBean.routeUrl.checkValue())
            nameList.add(topBannerBean.name)
        }
        bean.bannerRule?.let {
            BannerSizeUtil.setBannerSizeValue(binding.includeTop.banner, it.wide, it.high)
        }
        binding.includeTop.banner.setImageLoader(GlideImageLoader(3))
        binding.includeTop.banner.setDelayTime(5000)
        binding.includeTop.banner.setBannerStyle(BannerConfig.CUSTOM_INDICATOR)
        binding.includeTop.banner.setBannerAnimation(Transformer.Default)
        binding.includeTop.banner.setIndicatorGravity(BannerConfig.CENTER)
        binding.includeTop.banner.setImages(bannerList)
        binding.includeTop.banner.setIndicatorGravity(BannerConfig.CENTER)
        binding.includeTop.banner.setOnBannerListener(object : OnBannerListener {
            override fun OnBannerClick(position: Int) {
                if (bean.bannerConfigs.size > 0 && attachActivity.checkNotNull()) {
                    SensorsDataManager.instance.shopBannerClick(bean.bannerConfigs[position].name.checkValue())
                    ARouterUtils.bannerJump(attachActivity, bean.bannerConfigs[position].routeType, bean.bannerConfigs[position].routeUrl, bean.bannerConfigs[position].appletId)
                }
            }
        })
        binding.includeTop.banner.setOnPageChangeListener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrollStateChanged(state: Int) {

            }

            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
            }

            override fun onPageSelected(position: Int) {
                binding.includeTop.indicatorPicture.setCurrentShowView(position)
            }
        })
        binding.includeTop.banner.start()
        binding.includeTop.indicatorPicture.setSumCount(data.size)
        //banner指示器
        binding.includeTop.indicatorPicture.visibility = if (data.size > 1) View.VISIBLE else View.GONE

    }

    //广告
    private fun initBannerAd(bean: HomeMallInfoBean) {
        binding.includeTop.llAdRoot.visibility = if (bean.tuijAdvertList.size == 0) View.GONE else View.VISIBLE
        val adimgurls = arrayListOf<String>()
        val adRouterList = arrayListOf<String>()
        val nameList = arrayListOf<String>()
        for (bannerBean in bean.tuijAdvertList) {
            adimgurls.add(bannerBean.imgUrl.checkValue())
            adRouterList.add(bannerBean.routeUrl.checkValue())
            nameList.add(bannerBean.name.checkValue())
        }
        binding.includeTop.bannerAd.setImageLoader(GlideImageLoader(3))
        binding.includeTop.bannerAd.setDelayTime(5000)
        binding.includeTop.bannerAd.setBannerStyle(BannerConfig.CUSTOM_INDICATOR)
        binding.includeTop.bannerAd.setBannerAnimation(Transformer.Default)
        binding.includeTop.bannerAd.setIndicatorGravity(BannerConfig.CENTER)
        binding.includeTop.bannerAd.setImages(adimgurls)
        binding.includeTop.bannerAd.setIndicatorGravity(BannerConfig.CENTER)
        binding.includeTop.bannerAd.setOnBannerListener(IpOnBannerListener(activity, adRouterList, nameList, 0))
        binding.includeTop.bannerAd.start()
        val youxAdvertList = bean.youxAdvertList
        if (youxAdvertList.size > 0) {
            binding.includeTop.rivAd1.visibility = View.VISIBLE
            GlideLoader.LoderLoadReleaseCoverImagePlaceholder(requireContext(), youxAdvertList[0].imgUrl.checkValue(), binding.includeTop.rivAd1, 8, R.drawable.img_poster_three_bg_bottom)
            binding.includeTop.rivAd1.setOnClickListener {
                SensorsDataManager.instance.shopAdClick(youxAdvertList[0].name.checkValue(), "优选广告")
                ARouterUtils.jump(youxAdvertList[0].routeUrl)
            }
            if (youxAdvertList.size > 1) {
                binding.includeTop.rivAd2.visibility = View.VISIBLE
                GlideLoader.LoderLoadReleaseCoverImagePlaceholder(requireContext(), youxAdvertList[1].imgUrl.checkValue(), binding.includeTop.rivAd2, 8, R.drawable.img_poster_three_bg_bottom)
                binding.includeTop.rivAd2.setOnClickListener {
                    SensorsDataManager.instance.shopAdClick(youxAdvertList[1].name.checkValue(), "优选广告")
                    ARouterUtils.jump(youxAdvertList[1].routeUrl)
                }
            } else {
                //隐藏
                binding.includeTop.rivAd2.visibility = View.GONE
            }
        } else {
            //隐藏
            binding.includeTop.rivAd1.visibility = View.GONE
        }
    }

    //新人专享
    private fun initNewEnjoy(newEnjoyList: List<NewManEnjoySpuBean>) {
        binding.includeTop.rlNewEnjoy.visibility = if (newEnjoyList.size == 0) View.GONE else View.VISIBLE
        binding.includeTop.rvNewEnjoy.adapter = newEnjoyAdapter
        newEnjoyAdapter.setOnItemClickListener { adapter, view, position ->
            val newManEnjoySpuBean = adapter.data[position] as NewManEnjoySpuBean
            val hashMap: HashMap<String, Any> = hashMapOf()
            hashMap[Constants.GOODS_DETAIL_ID] = newManEnjoySpuBean.id
            hashMap[Constants.GOODS_DETAIL_SOURCE] = "新人专享页"
            ARouterUtils.jump(ActivityRouter.NEW_RETAIL.GOODS_DETAUILS, hashMap)
        }
        if (newEnjoyList.size > 10) {
            newEnjoyAdapter.setNewData(newEnjoyList.subList(0, 10))
        } else {
            newEnjoyAdapter.setNewData(newEnjoyList)
        }
        binding.includeTop.llNewEnjoySeeMore.visibility = if (newEnjoyList.size > 5) View.VISIBLE else View.GONE
        if (newEnjoyList.size > 5) {
            binding.includeTop.mhs.setKickBack(true)
            binding.includeTop.llNewEnjoySeeMore.visibility = View.VISIBLE
        } else {
            binding.includeTop.mhs.setKickBack(false)
            binding.includeTop.llNewEnjoySeeMore.visibility = View.GONE
        }
    }

    @SuppressLint("NotifyDataSetChanged")
    private fun initTab() {
        binding.rvTab.layoutManager = centerLayoutManager;
        centerLayoutManager.orientation = LinearLayoutManager.HORIZONTAL;
        binding.rvTab.adapter = mallTabAdapter

        mallTabAdapter.setOnItemClickListener { _, _, position ->
            mallTabAdapter.upSelected(position)
            binding.viewPager.currentItem = position
            //置顶
            binding.ablTop.setExpanded(false)//折叠appBar
            binding.llBottomVp.setBackgroundResource(if (mallTabAdapter.data[position].displayFormat == 1) R.drawable.bg_solid_white_r8 else R.drawable.bg_solid_f9f9f9_r8)
        }
        binding.viewPager.adapter = mTabPagerAdapter

        binding.viewPager.addOnPageChangeListener(object : ViewPager.OnPageChangeListener {
            override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
            }

            override fun onPageSelected(position: Int) {
                mallTabAdapter.upSelected(position)
                centerLayoutManager.smoothScrollToPosition(binding.rvTab, RecyclerView.State(), position)
                binding.llBottomVp.setBackgroundResource(if (mTabPagerAdapter.mTitles[position].displayFormat == 1) R.drawable.bg_solid_white_r8 else R.drawable.bg_solid_f9f9f9_r8)
            }

            override fun onPageScrollStateChanged(state: Int) {
            }
        })
    }

    private fun initMenu() {
        binding.includeTop.rvMenu.adapter = menuAdapter
        binding.includeTop.indicatorMenu.bindRecyclerView(binding.includeTop.rvMenu)

    }

    private fun initObserver() {
        mViewModel.homeDataLD.observe(viewLifecycleOwner, Observer {
            binding.smartRefresh.finishRefresh()
            if (it.checkNotNull()) {
                setMallInfoData(it)
            }
        })
        mViewModel.categoryLD.observe(viewLifecycleOwner, Observer {
            //商品分类
            if (it.checkNotNull()) {
                initGoodsTab(it)
            }
        })
        //购物车数量
        mViewModel.shopCartNumLD.observe(viewLifecycleOwner, Observer {
            SensorsDataManager.instance.shopVisit()
            if (it.checkNotNull()) {
                val tempCnt = it.count
                //购物车数量
                binding.tvCartNum.setVisibility(if (tempCnt > 0) View.VISIBLE else View.INVISIBLE)
                CommonUtil.formatNum99(binding.tvCartNum, tempCnt)
                binding.tvCartNum.setBackgroundResource(if (tempCnt > 99) R.drawable.dot_solid_red_rect else R.drawable.dot_solid_red)
            }
        })
        //banner
        mViewModel.bannerConfigListLD.observe(viewLifecycleOwner, Observer {
            //顶部banner
            if (it != null) {
                if (it.bannerConfigs.checkNotNull() && it.bannerConfigs.size > 0) {
                    binding.includeTop.flBanner.setVisibility(View.VISIBLE)
                    initBanner(it)
                } else {
                    binding.includeTop.flBanner.setVisibility(View.GONE)
                }
                binding.includeTop.vTemp.visibility = if (it.bannerConfigs.size == 0) View.VISIBLE else View.GONE
                binding.llTop.setBackgroundColor(ContextCompat.getColor(requireContext(), if (it.bannerConfigs.size == 0) R.color.white else R.color.transparent))
                tempTotalBannerSize = it.bannerConfigs.size
            }
        })
        //搜索热词轮播
        mViewModel.hotWordListLD.observe(viewLifecycleOwner, Observer { it ->
            searchKeyList.clear()
            for (data in it) {
                searchKeyList.add(data.name)
            }
            initSearch()
        })
    }

    private fun setMallInfoData(infoBean: HomeMallInfoBean) {
        mDataBean = infoBean
        binding.llLoading.visibility = View.GONE
        //菜单
        val list = arrayListOf<List<JinGIcon>>()
        if (infoBean.jinGIconList.size <= 10) {
            val temp = arrayListOf<JinGIcon>()
            for (infoBean in infoBean.jinGIconList) {
                temp.add(infoBean)
            }
            list.add(temp)
        } else if (infoBean.jinGIconList.size in 11..20) {
            val temp = arrayListOf<JinGIcon>()
            for (position in 0 until 10) {
                temp.add(infoBean.jinGIconList[position])
            }
            list.add(temp)
            val temp1 = arrayListOf<JinGIcon>()
            for (position in 10 until infoBean.jinGIconList.size) {
                temp1.add(infoBean.jinGIconList[position])
            }
            list.add(temp1)
        } else if (infoBean.jinGIconList.size in 21..30) {
            val temp = arrayListOf<JinGIcon>()
            for (position in 0 until 10) {
                temp.add(infoBean.jinGIconList[position])
            }
            list.add(temp)
            val temp1 = arrayListOf<JinGIcon>()
            for (position in 10 until 20) {
                temp1.add(infoBean.jinGIconList[position])
            }
            list.add(temp1)
            val temp2 = arrayListOf<JinGIcon>()
            for (position in 20 until infoBean.jinGIconList.size) {
                temp2.add(infoBean.jinGIconList[position])
            }
            list.add(temp2)
        }
        menuAdapter.setNewData(list)
        binding.includeTop.rvMenu.visibility = if (infoBean.jinGIconList.size == 0) View.GONE else View.VISIBLE
        binding.includeTop.indicatorMenu.visibility = if (list.size == 1) View.GONE else View.VISIBLE
        //新人专享
        if (infoBean.newManEnjoyPageList.size > 0) {
            binding.includeTop.imgNewJoy.load(requireContext(), infoBean.newManEnjoyPageList[0].cover.checkValue())
        }
        initNewEnjoy(infoBean.newManEnjoySpuList)
        //广告
        initBannerAd(infoBean)
        //请求商品分类
        mViewModel.requestCategoryList()
    }

    //商品分类
    private fun initGoodsTab(tabList: List<MallTabBean>) {
        //tab 赋值
        if (tabList.size > 0) {//默认选中第一个
            tabList[0].isSelect = true
        }
        mallTabAdapter.setNewData(tabList)
        //商品分类列表
        val fragmentList = arrayListOf<Fragment>()
        val mTitles = arrayListOf<MallTabBean>()
        tabList.forEachIndexed { index, tabBean ->
            fragmentList.add(MallGoodListFragment.newInstance("${tabBean.id}", tabBean.displayFormat == 1))
            mTitles.add(MallTabBean(tabBean.cover.checkValue(), tabBean.displayFormat, tabBean.id, tabBean.name.checkValue(), tabBean.sort, false))
        }
        binding.viewPager.currentItem = 0
        binding.viewPager.offscreenPageLimit = tabList.size
        mTabPagerAdapter.setFragments(fragmentList, mTitles)
        mTabPagerAdapter.notifyDataSetChanged()
    }

    private fun initListener() {
        binding.smartRefresh.setOnRefreshListener {
            requestData()
            EventBusUtils.sendNotify(MessageBus.msgId_refresh_home_goods_list)
        }
        binding.tvOpenSearch.setOnClickListener(this)
        binding.llSearch.setOnClickListener(this)
        binding.toolbar.setBackgroundColor(Color.argb(0, 255, 255, 255))
        binding.ablTop.addOnOffsetChangedListener(AppBarLayout.OnOffsetChangedListener { _, verticalOffset ->
            val offset = ScreenUtils.dpToPx(172)
//            HKLogUtils.e("-----------${verticalOffset}---${offset}")
            val a = (255 * (-verticalOffset / offset.toFloat())).toInt()
            binding.toolbar.setBackgroundColor(Color.argb(if (a >= 255) 255 else a, 255, 255, 255))
            if (a == 0 && tempTotalBannerSize != 0) {
                //默认
                binding.tvOpenSearch.setTextColor(ContextCompat.getColor(requireContext(), R.color.color_D8D8D8))
                binding.llSearch.setBackgroundResource(R.drawable.bg_solid_white_r30)
                GlideUtils.loadImg(requireContext(), R.drawable.ic_customer_white, binding.imgCustomer)
                GlideUtils.loadImg(requireContext(), R.drawable.ic_shop_cart_white, binding.imgShopCart)
            } else if (a >= 255) {
                //划上去了
                topSearchUI()
            } else if (tempTotalBannerSize == 0) {
                topSearchUI()
            }
        })
        binding.includeTop.mhs.setOnKickBackCallBack {
            //查看更多
            openNewEnjoyPage()
        }
        //购物车
        binding.imgShopCart.setOnClickListener(this)
        //新人专享 网页
        binding.includeTop.imgNewJoy.setOnClickListener(this)
        binding.includeTop.llNewEnjoySeeMore.setOnClickListener(this)
        binding.flCustomer.setOnClickListener(this)
        getMeiQiaNoReadCnt()
    }

    //划上去，
    private fun topSearchUI() {
        if (searchKeyList.size == 0) {
            binding.tvOpenSearch.setTextColor(ContextCompat.getColor(requireContext(), R.color.color_999999))
            binding.tvOpenSearch.setBackgroundResource(R.drawable.bg_solid_f0f0f0_r30)
        } else {
            binding.tvOpenSearch.setTextColor(ContextCompat.getColor(requireContext(), R.color.color_999999))
            binding.llSearch.setBackgroundResource(R.drawable.bg_solid_f0f0f0_r30)
        }
        GlideUtils.loadImg(requireContext(), R.drawable.ic_customer_black, binding.imgCustomer)
        GlideUtils.loadImg(requireContext(), R.drawable.ic_shop_cart_black, binding.imgShopCart)
    }

    //客服未读消息
    private fun getMeiQiaNoReadCnt() {
        //这里执行相应的代码，UI线程
        MQManager.getInstance(context).getUnreadMessages(object : OnGetMessageListCallback {
            override fun onSuccess(list: List<MQMessage>) {
                val tempCnt = list.size
                binding.tvCustomerNum.setVisibility(if (tempCnt > 0) View.VISIBLE else View.INVISIBLE)
                CommonUtil.formatNum99(binding.tvCustomerNum, tempCnt)
                binding.tvCustomerNum.setBackgroundResource(if (tempCnt > 99) R.drawable.dot_solid_red_rect else R.drawable.dot_solid_red)
            }

            override fun onFailure(i: Int, s: String) {}
        })
    }

    private fun requestData() {
        //请求banner
        mViewModel.reqGetHotWordList(1)
        mViewModel.reqGetBannerConfigList(1)
        mViewModel.requestHomeMallInfo()
        //请求商品分类
        mViewModel.requestCategoryList()
    }

    //EventBus 接受方法
    @Subscribe(threadMode = ThreadMode.MAIN)
    fun onEvent(messageBus: MessageBus) {
        if (messageBus.codeType == MessageBus.msgid_login_success) {
            //登录成功刷新 讲坛、专栏
            binding.smartRefresh.autoRefresh()
        } else if (messageBus.codeType == MessageBus.msgId_mei_qia_have_new_msg) {
            getMeiQiaNoReadCnt()
        } else if (messageBus.codeType == MessageBus.msgId_hide_meiqia_red_dot) {
            //已读
            binding.tvCustomerNum.setVisibility(View.INVISIBLE)
        } else if (messageBus.codeType == MessageBus.msgId_refresh_un_read_msg_cnt) {
            getMeiQiaNoReadCnt()
        } else if (messageBus.codeType == MessageBus.msgId_refresh_mall) {
//            binding.ablTop.behavior.onNestedFling(binding.clMall, null, null, 0f, -10000f, true)
            binding.smartRefresh.postDelayed(Runnable {
                binding.smartRefresh.autoRefresh()
            },100)

        }
    }

    private var hidden = false

    override fun onHiddenChanged(hidden: Boolean) {
        super.onHiddenChanged(hidden)
        this.hidden = hidden
        if (!hidden) {
            if (searchKeyList.size > 1) {
                binding.marqueeView.startFlipping()
            }
            mViewModel.reqShopCartNum()
            //界面重新显示
            //获取页面开始时间
            SensorsDataManager.instance.onCreateTime()
            StatusBarUtil.setStatusBarDarkTheme(activity, true)
        } else {
            binding.marqueeView.stopFlipping()
            SensorsDataManager.instance.onDestroyTime()
            if (SensorsDataManager.instance.getBrowseTime() != 0L) {

            }
        }
    }

    override fun onResume() {
        super.onResume()
        if (!hidden) {
            mViewModel.reqShopCartNum()
        }
    }

    override fun onDestroy() {
        super.onDestroy()
        if (EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().unregister(this)
        }
    }

    override fun onClick(v: View) {
        when (v.id) {
            R.id.img_shop_cart -> {
                if (!SpUtils.getInstance().isLogin) {
                    AppManager.getAppManager().openLoginPage()
                    return
                }
                //购物车
                SensorsDataManager.instance.shopCartSee("商城页")
                val map = java.util.HashMap<String, Any>()
                map[Constants.SHOP_CART_SOURCE] = "商城页"
                ARouterUtils.jump(ActivityRouter.NEW_RETAIL.SHOP_CART, map)
            }
            R.id.ll_new_enjoy_see_more, R.id.img_new_joy -> {
                //新人专享 网页
                openNewEnjoyPage()
            }
            R.id.fl_customer -> {
                //客服
                if (!DoubleClickHelper.isOnDoubleClick()) {
                    ARouterUtils.jump(ActivityRouter.MINE_CENTER.CUSTOMER_SERVICE, requireActivity())
                    binding.tvCustomerNum.postDelayed(Runnable { sendNotify(MessageBus.msgId_hide_meiqia_red_dot) }, 1000)
                }
            }
            R.id.tv_open_search -> {
                //打开搜索
                if (!DoubleClickHelper.isOnDoubleClick()) {
                    val bundle = Bundle()
                    bundle.putInt(IntentKey.SEARCH_TYPE, 1)
                    ActivityRouter.startActivity(ActivityRouter.ACTIVITY.SEARCH_ALL, bundle)
                }
            }
        }
    }

    //新人专享 网页
    private fun openNewEnjoyPage() {
        mDataBean?.let {
            if (it.newManEnjoyPageList.size > 0) {
                ARouterUtils.jump(it.newManEnjoyPageList[0].routeUrl)
            }
        }
    }
}